<?php
/**
 * File:insertATeamUser.php
 * @author: CIS505 A-Team (aka team1)
 * @version: 2012-11-29
 * Purpose: to create an admin login if database rebuilt
 */
require_once("php/util.php");

insertATeamUser( );

/**
 * inserts the ATeam Adim user into the database
 */
function insertATeamUser( )
{
  $salt1 = "qm&h*";
  $salt2 = "pg!@";

  $foreName = "ateam";
  $surName = "user";
  $userName = "ateam";
  $eMail = 'cis505ATeam@gmail.com';
  $password = "password";
  $token = sha1("$salt1$password$salt2");
    
  $conn = connect( );
  $query = "INSERT INTO user VALUES(
    NULL,'$foreName', '$surName', '$userName', '$eMail', '$password', '$token',NULL)";

  $resource = mysqli_query($conn, $query);

  if ($resource == false) {
    exit("Database error: $query<br />" . mysqli_error($conn));
  }
  
  echo <<<_END
    <p>A new user has been added to user table.</p><br />
    User Name: <strong>$userName</strong><br />
    Password: <strong>$password</strong><br />
    Click Here: <a href="index.php">Click Here</a><br />
_END;
  
}

?>